<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>
</head>
<body>
	<script type="text/javascript">
		//1.求下面数组的平均值
		var arr1 = [1, 6, 7, 20, 30]
		let n = 0

		arr1.forEach(function(value,index,array,){
			console.log("value---,", value, "index---,", index, "原数组---,", array)
			n += value
			})
			console.log(n/arr1.length)
		//2.找出数组最大值
		var arr2 = [3, 4, 6, 40, 54, 20, 15]
		let a = arr2[0]

		arr2.forEach(function(value,index){
			if(a < value){
				a = value	
				}
			})
			console.log(a)

		//2.找出数组的最大值并放到最后
		var arr3 = [3, 4, 6, 40, 54, 20, 15]
		for (let i = 0; i < arr3.length; i++){
			if (arr3[i] > arr3[i + 1]) {
				var temp = arr3[i]
				arr3[i] = arr3[i + 1]
				arr3[i + 1] = temp
			}
		}
		console.log(arr3)
	</script>
</body>
</html>